﻿import { Component } from '@angular/core';
import { NavController, NavParams } from 'ionic-angular';
import { PostService } from '../../services/post.service';
import { Loading } from '../../components/loading';

@Component({
  selector: 'page-post',
  templateUrl: 'post.html'
})
export class PostPage {
  post: any;

  constructor(
      public navCtrl: NavController, 
      public navParams: NavParams,
      public postService: PostService,
      private loading: Loading,
    ) {
    // If we navigated to this page, we will have an item available as a nav param
    this.post = navParams.get('post');
    this.getPost();
  }


  getPost():void {
      this.loading.presentLoading();
      this.postService.getPost(this.post.id).then(post => {
      this.post = post;
      this.loading.dismiss();
    });
  }
}
